package SwingView.Gradebook;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import JDBC.InstructorGradebookActivities;
import JDBC.StudentGradebookActivities;
import SwingController.CmsPresenter;
import SwingModel.CmsGradebook;
import SwingModel.CmsInstructor;
import SwingModel.CmsStudent;
import SwingModel.CmsUser;
import SwingView.CmsMainView;
import SwingView.CmsPageSelector.CmsPage;
import SwingView.Lecture.CmsCPInstructorLecture;
import SwingView.Lecture.CmsCPStudentLecture;

public class ALGradebook implements ActionListener{
	//---------------------------------------------------------
	//PERFORMING ACTION:
	//---------------------------------------------------------		
	@Override
	public void actionPerformed(ActionEvent e){
		
		//.....................................................
		//INSTRUCTOR CASE:
		if (CmsPresenter.user instanceof CmsInstructor){
			CmsGradebook gradebook = InstructorGradebookActivities.getGradebook(CmsPresenter.user.getSelectedCourse().getCourseID());
			System.out.println("GRADEBOOK:\n" + gradebook.toString());
			//Highlight the Gradebook Button
			CmsPresenter.mainView.displayGradebookInstructorPage(gradebook);
		}
		
		//.....................................................
		//STUDENT CASE:
		else{//Student case
			CmsGradebook gradebook = StudentGradebookActivities.getGradebook(CmsPresenter.user.getSelectedCourse().getCourseID(),(CmsStudent)CmsPresenter.user);
			System.out.println("GRADEBOOK:\n" + gradebook.toString());
			//Highlight the Gradebook Button
			CmsPresenter.mainView.displayGradebookStudentPage(gradebook);
		}
	}
}
